import React , { PureComponent , PropTypes } from 'react';

export default class Coat extends PureComponent {

    componentWillMount() {
         this.createLoading();
    }

    createLoading(){
        const preNode = document.createElement("div");
        preNode.innerHTML = `<div id="global-loading" style="display: none"></div>`;
        this.loadingNode = preNode.childNodes[0];
        document.body.appendChild(this.loadingNode);
        let nodeStyle = this.loadingNode.style;
        window.loading = () => {
            nodeStyle.display="block";
            return nodeStyle;
        }

        window.loadingClose=()=> {
            nodeStyle.display="none";
            return nodeStyle;
        }
    }

    render(){
        return this.props.children;
    }
}